package com.lz.all;

/**
 * StaticProxyDemo.. 静态代理 {原对象 代理人 客户 均要实现接口原对象}
 *
 * @author Lizhong
 * @date 2019/5/8
 */
public class StaticProxyDemo {
    public static void main(String[] args) {
        Proxy proxy = new Proxy();
        proxy.sale();
    }
}

/**
 * 原对象
 */
interface Source {
    void sale();
}

class SourceImpl implements Source {

    @Override
    public void sale() {
        System.out.println("卖产品了");
    }
}

/**
 * 代理对象
 */
class Proxy implements Source {
    private Source source;

    public Proxy() {
        source = new SourceImpl();
    }

    @Override
    public void sale() {
        this.source.sale();
    }
}
